package com.zprmb.udzt;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;

import com.zprmb.udzt.fragment.Ex_GoldFragment;
import com.zprmb.udzt.fragment.PagerSlidingTabStrip;

public class ExperienceGoldInfo extends BaseActivity implements OnClickListener{
	private PagerSlidingTabStrip tabs;
	private DisplayMetrics dm;
	private ViewPager pager;
	private MyPagerAdapter adapter;
	private RelativeLayout rl_back;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ex_gold_info);
		initView();
	}
	private void initView() {
		dm = getResources().getDisplayMetrics();
		tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
		pager = (ViewPager) findViewById(R.id.pager);
		adapter = new MyPagerAdapter(getSupportFragmentManager());
		pager.setOffscreenPageLimit(2);
		pager.setAdapter(adapter);
		rl_back=(RelativeLayout)findViewById(R.id.rl_back);
		rl_back.setOnClickListener(this);
		final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0, getResources()
				.getDisplayMetrics());
		pager.setPageMargin(pageMargin);
		tabs.setViewPager(pager);
		tabs.setUnderlineHeight(0);
		
		
	}
	public class MyPagerAdapter extends FragmentPagerAdapter {

		private final String[] TITLES = {"待使用","已使用","已过期"};
		private final String[] STATUS = {"getServiceNew/", "getServiceMy/","1"};

		public MyPagerAdapter(FragmentManager fm) {
			super(fm);
		}

		public CharSequence getPageTitle(int position) {
			return TITLES[position];
		}

		public int getCount() {
			return TITLES.length;
		}

		public Fragment getItem(int position) {
			
				return Ex_GoldFragment.newInstance(position,TITLES[position],getToken());
			
				
			
			
		}
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.rl_back:
			finish();
			break;
		}
		
	}
}
